//
//  ZCLoginRegisterViewController.m
//  ZCBaiSi
//
//  Created by zc on 16/7/8.
//  Copyright © 2016年 zc. All rights reserved.
//

#import "ZCLoginRegisterViewController.h"

@interface ZCLoginRegisterViewController ()
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *leftMargin;
@end

@implementation ZCLoginRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    //KVC设置圆角
  //  self.loginBtn.layer.masksToBounds = YES;
    //[self.loginBtn setValue:@YES forKeyPath:@"layer.masksToBounds"];
   // self.loginBtn.layer.cornerRadius = 5;
    //[self.loginBtn setValue:@5 forKeyPath:@"layer.cornerRadius"];
    
}

//显示登录或者注册界面
- (IBAction)showLoginOrRegister:(UIButton *)sender {
    //退出键盘
    [self.view endEditing:YES];
    
    if (self.leftMargin.constant) {//目前显示的是注册界面
        self.leftMargin.constant = 0;
        [sender setTitle:@"注册账号" forState:UIControlStateNormal];
    }else{//目前显示的是登录界面
         self.leftMargin.constant = - self.view.zc_width;
        [sender setTitle:@"已有账号?" forState:UIControlStateNormal];
    }
    [UIView animateWithDuration:0.35 animations:^{
        //修改UI界面的代码
        //强制刷新：让最新设置的约束值马上作用到UI控件上
        [self.view layoutIfNeeded];
    }];
}

//改变状态栏样式
- (UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)close:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

//隐藏状态栏
//- (BOOL)prefersStatusBarHidden{
//    return YES;
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
